home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
- # postinst script for hpijs
- # $Id: $
- #
- # see: dh_installdeb(1)
-
- set -e
-
- # summary of how this script can be called:
- # * <postinst> `configure' <most-recently-configured-version>
- # * <old-postinst> `abort-upgrade' <new version>
- # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
- # <new-version>
- # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
- # <failed-install-package> <version> `removing'
- # <conflicting-package> <version>
- # for details, see http://www.debian.org/doc/debian-policy/ or
- # the debian-policy package
- #
- # quoting from the policy:
- # Any necessary prompting should almost always be confined to the
- # post-installation script, and should be protected with a conditional
- # so that unnecessary prompting doesn't happen if a package's
- # installation fails and the `postinst' is called with `abort-upgrade',
- # `abort-remove' or `abort-deconfigure'.
-
- case "$1" in
- configure)
- # Do the following only if CUPS is running and the needed CUPS tools
- # are available
- if which lpstat > /dev/null 2>&1 && \
- which lpinfo > /dev/null 2>&1 && \
- which lpadmin > /dev/null 2>&1 && \
- LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not > /dev/null 2>&1; then
- # Update the PPD files of all already installed print queues
- driverregexp='drv:///hpijs.drv/|lsb/usr/hplip/HP/HP-Fax.*-hpijs'
- gennicknameregexp='s/,?\s*hpcups,?\s+[\d\.]+[a-zA-Z]*\s*$//; s/,?(\s*hpijs,?|,)\s*[\d\.]+[a-zA-Z]*\s*$//; s/\s*(Foomatic\/|)(hpijs|hpcups)(\s*\S+|)$//i; s/\s*Series$//i; s/(HP\s+)PhotoSmart(\s+)/\1PS\2/i; s/(HP\s+)DeskJet(\s+)/\1DJ\2/i; s/(HP\s+)Color\s*(LaserJet|LJ)(\s+)/\1CLJ\3/i; s/(HP\s+)LaserJet(\s+)/\1LJ\2/i; s/(HP\s+)OfficeJet(\s+)/\1OJ\2/i; s/(HP\s+)Business\s*InkJet(\s+)/\1BIJ\2/i; s/(HP\s+)DesignJet(\s+)/\1DESIGNJ\2/i; s/(HP\s+)Printer\s*Scanner\s*Copier(\s+)/\1PSC\2/i; s/(HP\s+)Color\s*InkJet\s*Printer\s+/\1/i; s/\s+(zjs|zxs|pcl3)//i'
- [ ! -z "$gennicknameregexp" ] && \
- gennicknameregexp="; $gennicknameregexp"
- gennicknameregexp='s/\s*\(recommended[^\)]*\)//'"$gennicknameregexp"
- tempfiles=
- trap 'rm -f $tempfiles; exit 0' 0 HUP INT QUIT ILL ABRT PIPE TERM
- tmpfile1=`mktemp -t updateppds.XXXXXX`
- tempfiles="$tempfiles $tmpfile1"
- lpinfo -h /var/run/cups/cups.sock -m | grep -E $driverregexp > $tmpfile1
- cd /etc/cups/ppd
- for ppd in *.ppd; do
- [ -r "$ppd" ] || continue
- queue=${ppd%.ppd}
- lpstat -h /var/run/cups/cups.sock -p "$queue" >/dev/null 2>&1 || continue
- nickname=`grep '\*NickName:' "$ppd" | cut -d '"' -f 2 | perl -p -e 's/\n$//' | perl -p -e "$gennicknameregexp" | perl -p -e 's/(\W)/\\\\$1/g'`
- lang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
- ppdfound="0"
- englishppduri=""
- tmpfile2=`mktemp -t updateppds.XXXXXX`
- tempfiles="$tempfiles $tmpfile2"
- cat $tmpfile1 | perl -p -e "$gennicknameregexp; s/\s*$/\n/" | grep -i '\b'"$nickname"'$' | cut -d ' ' -f 1 > $tmpfile2
- while read newppduri; do
- [ "$ppdfound" = "0" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $newppduri 2>/dev/null || continue
- newlang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
- [ "$newlang" = "$lang" ] && ppdfound="1"
- [ "$newlang" = "english" ] && englishppduri="$newppduri"
- done < $tmpfile2
- [ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
- [ "$ppdfound" = "1" ] && echo PPD for printer $queue updated >&2
- done
- fi
- ;;
-
- abort-upgrade|abort-remove|abort-deconfigure)
- ;;
-
- *)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
- esac
-
- # dh_installdeb will replace this with shell code automatically
- # generated by other debhelper scripts.
-
-
-
- exit 0
-